﻿using Microsoft.AspNetCore.Mvc;
using Net5ApiAndEfMySql.ApiProject.Common;
using Net5ApiAndEfMySql.DtoModel.SystemAdmin;
using Net5ApiAndEfMySql.IService.SystemAdmin;
using Net5CommonLib.SystemLib.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Net5ApiAndEfMySql.ApiProject.Controllers
{
    [Route("api/[controller]/[action]")]
    [ServiceFilter(typeof(UserTokenVerificationAttribute))] //使用ServiceFilter会自动将依赖注入注入到过滤器中
    [ApiController]
    public class BaseApiController : ControllerBase
    {
        public AdminUserDto LoginUser
        {
            get
            {
                return DiManager.GetDiObjScoped<IAdminUserService>().GetLoginUserByToken(Token);
            }
        }

        public string Token
        {
            get
            {
                return DiManager.GetDiObjScoped<IAdminUserService>().Token;
            }
        }
    }
}
